package com.example.wangfanwangluo.wangfanboss;

import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

@SuppressLint("ValidFragment")
public class MineFragment extends Fragment {
    private String mTitle;
    private TextView mycenter;
    private RelativeLayout kefu;
    private RelativeLayout shoucang;
    private TextView exitbtn;

    public static MineFragment getInstance(String title) {
        MineFragment sf = new MineFragment();
        sf.mTitle = title;
        return sf;
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fr_mine, null);
        mycenter = (TextView) v.findViewById(R.id.touch_mine);
        kefu = (RelativeLayout) v.findViewById(R.id.kefu2_mine);
        shoucang =(RelativeLayout) v.findViewById(R.id.shoucang_mine);
        exitbtn = (TextView)v.findViewById(R.id.exitbtn_mine);
       mycenter.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               //进入个人中心
               Intent intent = new Intent(getActivity(),mine.class);
               startActivity(intent);

           }
       });
        kefu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //进入客服界面
                Intent intent = new Intent(getActivity(),Kefu.class);
                startActivity(intent);

            }
        });
        shoucang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //提示。。暂未开通此服务
                Toast.makeText(getActivity(),"暂未开通此服务", Toast.LENGTH_SHORT).show();

            }
        });
        exitbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //退出登录 ..进入登录页面

                //清除token,回到登录页面
                //弹出alert ,确认是否退出登录。。。
                AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
                dialog.setTitle("提示");
                dialog.setMessage("确定退出当前账号?");
                dialog.setCancelable(true);
                dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        //进入登录界面
                        Intent intent = new Intent(getActivity(),Login.class);
                        startActivity(intent);
                    }
                });
                dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        //不做操作
                    }
                });
                dialog.show();
            }
        });

        return v;
    }
}